<?php
namespace Admin\Controller;
use Think\Controller;
use Think\Upload;

class SysController extends Controller {

    public function Sys(){
        if (!checkCookie()) {
            $this->redirect('Admin/Index/login');
        }
         $model = M('sys');
        if (!IS_POST) {
            $info = $model->where('sid=1')->find();
            $this->assign('sys',$info);
            $this->display();
        } else {
            //接收文件 调用文件上传
            $upload = new \Admin\Controller\MyUploadController();
            $info = $upload->upload();
            if (!$info) {
                $this->error("发布失败",(U('Admin/sys/sys')));
            } else {
                foreach ($info as $k => $v) {
                    $_POST[$k] = $v;
                }
                $_POST['ctime'] = time();
            }

            $data = $model->create();
            if($model->where('sid=1')->save()){
                $this->success("发布成功",(U('Admin/sys/sys')));
            }else{
                $this->error("发布失败",(U('Admin/sys/sys')));
            }
        }
    }
}

  